{template 'common/header'}
<ul class="nav nav-tabs">
	<li><a href="{php echo $this->createWebUrl('joke', array('op'=>'display'));}">笑话列表</a></li>
	<li {if empty($id)}class="active"{/if}><a href="{php echo $this->createWebUrl('joke', array('op'=>'edit'));}">添加笑话</a></li>
	{if !empty($id)}
	<li class="active"><a href="{php echo $this->createWebUrl('joke', array('op'=>'edit', 'id'=>$id));}">编辑笑话</a></li>
	{/if}
</ul>
<div class="main">
	<form action="" method="post" class="form-horizontal form" id="form">
		<div class="panel panel-default">
			<div class="panel-heading">笑话</div>
			<div class="panel-body">

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">品名</label>
					<div class="col-xs-12 col-sm-8">
						<input type="text" name="joke[title]" class="form-control" value="{$jokedb['title']}" />
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">内容</label>
					<div class="col-sm-8 col-xs-12">
						{php echo tpl_ueditor('joke[content]', $jokedb['content']);}
					</div>
				</div>

				<div class="form-group">
					<div class="col-xs-12 col-sm-9 col-md-10 col-lg-10 col-sm-offset-3 col-md-offset-2 col-lg-offset-2">
						<input type="hidden" name="id" value="{$jokedb['id']}" />
						<input name="submit" type="submit" value="提交" class="btn btn-primary" />
						<input type="hidden" name="token" value="{$_W['token']}" />
					</div>
				</div>

			</div>
		</div>
	</form>
</div>
<script>
require(['jquery', 'util'], function($, util){
	$(function(){
		$('#form').submit(function(){
			if($('input[name="title"]').val() == ''){
				util.message('请填写名称.');
				return false;
			}
			return true;
		});
	});
});
</script>
{template 'common/footer'}